-- 豌豆射手类
local Plant = require("app.mode.Plant")

local PeaShooter = {}
setmetatable(PeaShooter, Plant)
PeaShooter.__index = PeaShooter

-- 重写功能函数
function PeaShooter:doFunc()
    local x, y = self:getLogicPosition()
    -- 发射一颗豌豆
    if self._scene and Plant:getZCount(y) > 0 then
        x, y = self:getPosition()
        self:newWeapon("pea", x + 20, y + 24)
    end
end

function PeaShooter:newWeapon(name, x, y)
    local config = require("app.data.weapon." .. name)
    self._scene:newWeapon(config[1], config[2], x, y)
end

return PeaShooter
